﻿{include file="public/header" /}
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">系统设置</a>
        <a>
          <cite>配置管理</cite>
        </a>
      </span>
  <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
    <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body" >
  <xblock>
    <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>&nbsp;&nbsp;&nbsp;&nbsp;
    <button class="layui-btn" onclick="x_admin_show('添加配置','{:url(\'admin/Conf/add\')}',500,550)"><i class="layui-icon"></i>添加</button>
  </xblock>
  <div class="container-wrap">
    <div class="box-1">
      <table class="layui-table">
        <thead>
        <tr>
        <th width="10" style="text-align: center">
          <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i class="layui-icon">&#xe605;</i></div>
        </th>
          <th style="text-align: center" width="10">ID</th>
          <th style="text-align: center" width="20">英文名称</th>
          <th style="text-align: center" width="40">中文名称	</th>
          <th style="text-align: center" width="20">表单类型</th>
          <th style="text-align: center" width="50" >配置类型</th>
          <th style="text-align: center" width="50" >可选值	</th>
          <th style="text-align: center" width="50" >默认值</th>
          <th style="text-align: center" width="20" >排序</th>
          <th style="text-align: center" width="50">操作</th>
      </tr>
      </thead>
      <tbody>
      {volist name="confInfo" id="info"}
      <tr  style="text-align: center">
        <td>
          <div class="layui-unselect layui-form-checkbox" lay-skin="primary" data-id=''><i class="layui-icon">&#xe605;</i></div>
        </td>
        <td>{$info.id}</td>
        <td>{$info.ename}</td>
        <td>{$info.cname}</td>
        <td>{$info.form_type}</td>
        <td>
            {if $info.conf_type == 1}
              店铺配置
            {else}
              商品配置
            {/if}
        </td>
        <td>{$info.values}</td>
        <td>{$info.value}</td>
        <td>
            <div class="layui-input-inline listorder" style="width: 50px;">
                <input type="text" value="{$info.sort}" size="5" attr-id="{$info.id}" class="layui-input"  name="listorder" >
            </div>
        </td>
        <td class="td-manage" width="10">
            <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"  onclick="x_admin_show('修改配置','{:url(\'admin/Conf/edit\',[\'id\'=>$info.id])}',500,550)"><i class="layui-icon layui-icon-edit"></i>编辑</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del" onclick="delete_cate(this,'{$info.id}')"><i class="layui-icon layui-icon-delete"></i>删除</a>
        </td>
      </tr>
      {/volist}
      </tbody>
    </table>
    </div>
  </div>
  <div class="page">
    {$confInfo|raw}
  </div>
  <script>
    //排序
    $(".listorder input").blur(function () {
        var listorder =  $(this).val();
        var id = $(this).attr('attr-id');
        var url = "{:url('/admin/Conf/updateSort')}";
        var postData ={"id":id,"listorder":listorder,'table':"conf","value":"sort"};
        $.post(url,postData,function (result) {
            if(result == 1 ){
                layer.alert("更新成功", {icon: 6},function () {
                    window.location.reload();  //刷新父级页面
                });
            }else {
                layer.alert("更新失败", {icon: 5});
            }
        },"json")
    });

      layui.use('laydate', function(){
          var laydate = layui.laydate;
          //执行一个laydate实例
          laydate.render({
              elem: '#start' //指定元素
          });

          //执行一个laydate实例
          laydate.render({
              elem: '#end' //指定元素
          });
      });

      function delete_cate(obj,id){
          layer.confirm('确认要删除吗？',function(index){
              $.ajax({
                  url:"{:url('admin/Conf/delete')}",
                  type:"POST",
                  dataType:"json",
                  data:{
                      id:id  //id
                  },
                  success:function (res) {
                      if (res === 1){
                          $(obj).parents("tr").remove();
                          layer.msg('已删除!',{icon:1,time:1000});
                      }else {
                          layer.alert("更新失败", {icon: 5});
                      }
                  }
              });
          });
      }

      function delAll (argument) {
          var data = tableCheck.getData();
          layer.confirm('确认要删除吗？',function(index){
              //捉到所有被选中的，发异步进行删除
              $.ajax({
                  url:"/index/index/delall",
                  type:"POST",
                  dataType:"json",
                  data:{
                      table:"hy_drawing_detial",  //表名
                      data:data   //数据
                  },
                  success:function (res) {
                      layer.msg(res.message, {icon: 1});
                      $(".layui-form-checked").not('.header').parents('tr').remove();
                  },
              });
          });
      }
  </script>
</body>
</html>